// eslint-disable-next-line no-unused-vars
import { DbEntity } from '../entity/dbEntity.js'
import * as mySqlConn from '../../mysql/mySqlConn.js'
import * as bizError from '../../error/bizError.js'

const connMap = new Map()
connMap.set(DbEntity.MySql, mySqlConn)
/**
 * 获取服务
 * @param {string} datatype 
 * @returns 
 */
function getConn(datatype) {
  const conn = connMap.get(datatype)
  if (!conn) {
    throw bizError.VALID_FAIL
  }
  return conn
}
/**
 * 测试连接
 * @param {DbEntity} dbEntity 数据库对象
 * @returns {Promise<boolean>}
 */
export async function testConnect(dbEntity) {
  const conn = getConn(dbEntity.datatype)
  let result = await conn.testConnection(dbEntity)
  return result
}


/**
 * 保存
 * @param {DbEntity} dbEntity 数据库对象
 */
export async function save(dbEntity){
  //TODO 在此继续
}
